home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / jpi / events.bas < prev    next >
BASIC Source File  |  1998-01-26  |  3KB  |  73 lines

  1. Attribute VB_Name = "Events"
  2. Public Const Event_SpawnObject = 1
  3. Public Const Event_ObjectFire = 2
  4. Public Const Event_DestroyObject = 3
  5. Public Const Event_DirectUnit = 4
  6. Public Const Event_DeployUnit = 5
  7. Public Const Event_UpdateUnit = 6
  8.  
  9. Public Const MaxEventParamaters = 10
  10. Public Const EventDataLength = 4
  11. Public Type EventObj
  12.   EventType As Integer
  13.   Paramaters(MaxEventParamaters) As String
  14. End Type
  15. Public Sub RegisterEvent(EventObject As EventObj)
  16. If Internet.ServerData.ConnectedToServer = True Then
  17.   SendString$ = Format$(EventObject.EventType, "0000")
  18.   For I = 1 To MaxEventParamaters
  19.     SendString$ = SendString$ & Format$(EventObject.Paramaters(I), "0000")
  20.   Next I
  21.   Call Internet.SendData(CODE_EVENT, SendString$)
  22.   'Internet.WaitForIncomingData
  23. Else
  24.   Call RunEvent(EventObject)
  25. End If
  26. End Sub
  27. Public Sub SpawnEvent(EventType, Optional ByRef Param1, Optional ByRef Param2, Optional ByRef Param3, Optional ByRef Param4, Optional ByRef Param5, Optional ByRef Param6, Optional ByRef Param7, Optional ByRef Param8, Optional ByRef Param9, Optional ByRef Param10)
  28. Dim NewEvent As EventObj
  29. On Error Resume Next
  30. Select Case EventType
  31. End Select
  32. With NewEvent
  33.   .EventType = EventType
  34.   .Paramaters(1) = Param1
  35.   .Paramaters(2) = Param2
  36.   .Paramaters(3) = Param3
  37.   .Paramaters(4) = Param4
  38.   .Paramaters(5) = Param5
  39.   .Paramaters(6) = Param6
  40.   .Paramaters(7) = Param7
  41.   .Paramaters(8) = Param8
  42.   .Paramaters(9) = Param9
  43.   .Paramaters(10) = Param10
  44. End With
  45. Call RegisterEvent(NewEvent)
  46. End Sub
  47. Public Sub RunEvent(EventObject As EventObj)
  48. Select Case EventObject.EventType
  49. Case Event_SpawnObject
  50.   NewObject = Entities.SpawnObject(Val(EventObject.Paramaters(1)), Val(EventObject.Paramaters(2)), Val(EventObject.Paramaters(3)), Val(EventObject.Paramaters(4)), Val(EventObject.Paramaters(5)), Val(EventObject.Paramaters(6)), Val(EventObject.Paramaters(7)))
  51. Case Event_ObjectFire
  52.   Call Entities.ObjectCommand_Fire(Val(EventObject.Paramaters(1)), Val(EventObject.Paramaters(2)), Val(EventObject.Paramaters(3)), Val(EventObject.Paramaters(4)), Val(EventObject.Paramaters(5)))
  53. Case Event_DestroyObject
  54.   Call Entities.DestroyObject(Val(EventObject.Paramaters(1)))
  55. Case Event_DirectUnit
  56.   Call Entities.DirectUnit(Val(EventObject.Paramaters(1)), Val(EventObject.Paramaters(2)), Val(EventObject.Paramaters(3)), Val(EventObject.Paramaters(4)))
  57. Case Event_DeployUnit
  58.   Call Entities.ObjectCommand_Deploy(Val(EventObject.Paramaters(1)))
  59. Case Event_UpdateUnit
  60.   ObjIndex = Val(EventObject.Paramaters(1))
  61.   Objects(ObjIndex).Position.X = Val(EventObject.Paramaters(1))
  62.   Objects(ObjIndex).Position.Y = Val(EventObject.Paramaters(2))
  63.   Objects(ObjIndex).Position.Z = Val(EventObject.Paramaters(3))
  64.   Objects(ObjIndex).Vector.Yaw = Val(EventObject.Paramaters(4))
  65.   Objects(ObjIndex).CurrentSpeed = Val(EventObject.Paramaters(5))
  66.   Objects(ObjIndex).Objective.Goal = Val(EventObject.Paramaters(6))
  67.   Objects(ObjIndex).States(Val(EventObject.Paramaters(7))) = True
  68.   Objects(ObjIndex).Properties(PROPERTY_HEALTH) = Val(EventObject.Paramaters(8))
  69. End Select
  70. 'If .Side = LocalPlayer.PlayerIndex Then Call Events.SpawnEvent(Events.Event_UpdateUnit, Objindex, .Position.X, .Position.Y, .Position.Z, .Vector.Yaw, .CurrentSpeed, .Objective.Goal, .State, .Properties(PROPERTY_HEALTH))
  71. End Sub
  72.  
  73.